package com.chen.blog.controller;


import com.chen.blog.common.api.CommonResult;
import com.chen.blog.model.Score;
import com.chen.blog.service.ScoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author chen
 * @since 2022-01-24
 */
@Api(tags = "评分管理 ScoreController")
@RestController
@RequestMapping("/score")
public class ScoreController {

    @Autowired
    private ScoreService scoreService;

    @ApiOperation("检索不同分数区间下的博客数量")
    @GetMapping
    public Map<String, Object> findBlogByScore() {
        return scoreService.findBlogByScore();
    }

    @ApiOperation("新增评分")
    @PostMapping
    public CommonResult addScore(@RequestBody Score score) {
        return scoreService.addScore(score);
    }
}
